---
id: create-api-key
title: "Create Api Key"
description: "Creates an API key for a user."
sidebar_label: "Create Api Key"
hide_title: true
hide_table_of_contents: true
api: eJzVVU1v2zAM/SuCTitgJFmxk0/L2gENuqFFm22HtChUmYnVOJImyd0yw/99pGTno1mK7ThfYksU+fj4ntLwArx0ygZlNM/5mQMRwDOh2fh6wpawZnPjmGC1Bze403d67BY+v9MMHwffa/CBvblJLyc5m5awWTaPTyADk0YHobTSCxZwlxKxyTlTOn72wT5g3VjgBkLtdF/DB5eyyois6GENeMaNBScI+KRA6CngQVj1gPu4bYUTKwjgPM9nDadKygGGBldDxr0sYSV43vCwtoAJsBSCxINBhYoWvhm39FZIYFigzbjGdLj8o19+UAVGK+INm3Br3t5nWMZboz14ynw6GtHPPse3tZTg/byu2E0XjGmIJtCBwoW1lZKxs+GTpzPNX6Dtc7E0Qza2il0iES0+GX93enqI5KuoVBHrsI/OGfcvMKwj+oNKjRaAM67oTQVY+cOAysi9XaHXV/M4l/1+2myzohDJAhyyivi7NeGcWO80/ckkgDSelV+8xs9n5FwsgG+SHQ+NZLAp7bbb2knPPNtR0iz2lUp3cffbNFt6E7vH2zhP9P2pWB9yMZ1eHyRMs0WRl4YsYI0PUfihxK8h2sDjJxruuTdB7XBIvAzB+nw4lJWpiwGSgg4dCDVE72D8vkbGcZedUWgUuAdZOxXWMR+6ETV2AaLAQeWz+92AW9JKmv5+2IZ4rHcZrdo5a1xjI079SiPtrFWmU9So0nMTj3ecdNg+CLkETV6kPhPs0eDtYHSsme4A3SWd5IWMku9xxDDc2qdrQxTuoAtI7zyAWL3fbhBKmsJK6J18Lxz5AlWzNd3/df92UwzwMwxthTVI4ZGyptPgjEcNoihKkiZ+N82j8PDFVW1Ly+neJCUVyovHikw1F5WHVziK7ZL/TtgxEPQHcHBRP4uqptCo4mfhFNWLos16kRGQdHaMd7QNO6cObkPKsnHe9dXtFIf/Gzyyfac=
sidebar_class_name: "post api-method"
info_path: reference/api/agenta-backend
custom_edit_url: null
---

import ApiTabs from "@theme/ApiTabs";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
import MimeTabs from "@theme/MimeTabs";
import ParamsItem from "@theme/ParamsItem";
import ResponseSamples from "@theme/ResponseSamples";
import SchemaItem from "@theme/SchemaItem";
import SchemaTabs from "@theme/SchemaTabs";
import Markdown from "@theme/Markdown";
import Heading from "@theme/Heading";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Create Api Key"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/keys"}
>
  
</MethodEndpoint>



Creates an API key for a user.

Args:
    request (Request): The request object containing the user ID in the request state.

Returns:
    str: The created API key.

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
  children={"Request"}
>
</Heading>

<details
  style={{"marginBottom":"1rem"}}
  className={"openapi-markdown__details"}
  data-collapsed={false}
  open={true}
>
  <summary
    style={{}}
  >
    <h3
      className={"openapi-markdown__details-summary-header-params"}
    >
      Query Parameters
    </h3>
  </summary><div>
    <ul>
      <ParamsItem
        className={"paramsItem"}
        param={{"required":true,"schema":{"type":"string","title":"Workspace Id"},"name":"workspace_id","in":"query"}}
      >
        
      </ParamsItem>
    </ul>
  </div>
</details><div>
  <div>
    <ApiTabs
      label={undefined}
      id={undefined}
    >
      <TabItem
        label={"200"}
        value={"200"}
      >
        <div>
          
          
          Successful Response
          
          
        </div><div>
          <MimeTabs
            className={"openapi-tabs__mime"}
            schemaType={"response"}
          >
            <TabItem
              label={"application/json"}
              value={"application/json"}
            >
              <SchemaTabs
                className={"openapi-tabs__schema"}
              >
                <TabItem
                  label={"Schema"}
                  value={"Schema"}
                >
                  <details
                    style={{}}
                    className={"openapi-markdown__details response"}
                    data-collapsed={false}
                    open={true}
                  >
                    <summary
                      style={{}}
                      className={"openapi-markdown__details-summary-response"}
                    >
                      <strong>
                        Schema
                      </strong>
                    </summary><div
                      style={{"textAlign":"left","marginLeft":"1rem"}}
                    >
                      
                    </div><ul
                      style={{"marginLeft":"1rem"}}
                    >
                      <div
                        style={{"marginTop":".5rem","marginBottom":".5rem"}}
                      >
                        
                        
                        string
                        
                        
                      </div>
                    </ul>
                  </details>
                </TabItem>
              </SchemaTabs>
            </TabItem>
          </MimeTabs>
        </div>
      </TabItem><TabItem
        label={"422"}
        value={"422"}
      >
        <div>
          
          
          Validation Error
          
          
        </div><div>
          <MimeTabs
            className={"openapi-tabs__mime"}
            schemaType={"response"}
          >
            <TabItem
              label={"application/json"}
              value={"application/json"}
            >
              <SchemaTabs
                className={"openapi-tabs__schema"}
              >
                <TabItem
                  label={"Schema"}
                  value={"Schema"}
                >
                  <details
                    style={{}}
                    className={"openapi-markdown__details response"}
                    data-collapsed={false}
                    open={true}
                  >
                    <summary
                      style={{}}
                      className={"openapi-markdown__details-summary-response"}
                    >
                      <strong>
                        Schema
                      </strong>
                    </summary><div
                      style={{"textAlign":"left","marginLeft":"1rem"}}
                    >
                      
                    </div><ul
                      style={{"marginLeft":"1rem"}}
                    >
                      <SchemaItem
                        collapsible={true}
                        className={"schemaItem"}
                      >
                        <details
                          style={{}}
                          className={"openapi-markdown__details"}
                        >
                          <summary
                            style={{}}
                          >
                            <span
                              className={"openapi-schema__container"}
                            >
                              <strong
                                className={"openapi-schema__property"}
                              >
                                detail
                              </strong><span
                                className={"openapi-schema__name"}
                              >
                                 object[]
                              </span>
                            </span>
                          </summary><div
                            style={{"marginLeft":"1rem"}}
                          >
                            <li>
                              <div
                                style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}}
                              >
                                Array [
                              </div>
                            </li><SchemaItem
                              collapsible={true}
                              className={"schemaItem"}
                            >
                              <details
                                style={{}}
                                className={"openapi-markdown__details"}
                              >
                                <summary
                                  style={{}}
                                >
                                  <span
                                    className={"openapi-schema__container"}
                                  >
                                    <strong
                                      className={"openapi-schema__property"}
                                    >
                                      loc
                                    </strong><span
                                      className={"openapi-schema__name"}
                                    >
                                       object[]
                                    </span><span
                                      className={"openapi-schema__divider"}
                                    >
                                      
                                    </span><span
                                      className={"openapi-schema__required"}
                                    >
                                      required
                                    </span>
                                  </span>
                                </summary><div
                                  style={{"marginLeft":"1rem"}}
                                >
                                  <li>
                                    <div
                                      style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}}
                                    >
                                      Array [
                                    </div>
                                  </li><div>
                                    <span
                                      className={"badge badge--info"}
                                    >
                                      anyOf
                                    </span><SchemaTabs>
                                      <TabItem
                                        label={"MOD1"}
                                        value={"0-item-properties"}
                                      >
                                        <div
                                          style={{"marginTop":".5rem","marginBottom":".5rem"}}
                                        >
                                          
                                          
                                          string
                                          
                                          
                                        </div>
                                      </TabItem><TabItem
                                        label={"MOD2"}
                                        value={"1-item-properties"}
                                      >
                                        <div
                                          style={{"marginTop":".5rem","marginBottom":".5rem"}}
                                        >
                                          
                                          
                                          integer
                                          
                                          
                                        </div>
                                      </TabItem>
                                    </SchemaTabs>
                                  </div><li>
                                    <div
                                      style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}}
                                    >
                                      ]
                                    </div>
                                  </li>
                                </div>
                              </details>
                            </SchemaItem><SchemaItem
                              collapsible={false}
                              name={"msg"}
                              required={true}
                              schemaName={"Message (string)"}
                              qualifierMessage={undefined}
                              schema={{"type":"string","title":"Message"}}
                            >
                              
                            </SchemaItem><SchemaItem
                              collapsible={false}
                              name={"type"}
                              required={true}
                              schemaName={"Error Type (string)"}
                              qualifierMessage={undefined}
                              schema={{"type":"string","title":"Error Type"}}
                            >
                              
                            </SchemaItem><li>
                              <div
                                style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}}
                              >
                                ]
                              </div>
                            </li>
                          </div>
                        </details>
                      </SchemaItem>
                    </ul>
                  </details>
                </TabItem><TabItem
                  label={"Example (from schema)"}
                  value={"Example (from schema)"}
                >
                  <ResponseSamples
                    responseExample={"{\n  \"detail\": [\n    {\n      \"loc\": [\n        \"string\",\n        0\n      ],\n      \"msg\": \"string\",\n      \"type\": \"string\"\n    }\n  ]\n}"}
                    language={"json"}
                  >
                    
                  </ResponseSamples>
                </TabItem>
              </SchemaTabs>
            </TabItem>
          </MimeTabs>
        </div>
      </TabItem>
    </ApiTabs>
  </div>
</div>
      